

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>用户列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
  <style>

    /*td .layui-table-cell {*/
    /*  line-height: 80px;*/
    /*  height: 80px;*/
    /*}*/

    /*不隐藏直接换行*/
    /*.layui-table-cell, .layui-table-tool-panel li {*/
    /*  white-space: initial;*/
    /*  !*为了让字母和数字也换行*!*/
    /*  word-break: break-word;*/
    /*}*/

    td .laytable-cell-1-0-11 {
      line-height: 14px;
    }

    /*td .laytable-cell-1-0-11 {*/
    /*  line-height: 42px;*/
    /*}*/

  </style>
</head>
<body>

  <div class="layui-fluid">   
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="listSearch">
        <div class="layui-form-item">

          <div class="layui-inline">
            <label class="layui-form-label">关键词</label>
            <div class="layui-input-block">
              <input type="text" name="keyword" placeholder="用户ID / 绑定手机" autocomplete="off" class="layui-input">
            </div>
          </div>


          <div class="layui-inline">
            <label class="layui-form-label">用户token</label>
            <div class="layui-input-block">
              <input type="text" name="token" placeholder="请求头的token" autocomplete="off" class="layui-input">
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">设备ID</label>
            <div class="layui-input-block">
              <input type="text" name="userId" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>


          <div class="layui-inline">
            <label class="layui-form-label">App</label>
            <div class="layui-input-block">
              <select name="quick_id" lay-search>
                <option value="">请选择</option>
                {foreach $qas as $k => $v}
                <option value="{$v.id}">{$v.name}</option>
                {/foreach}
              </select>
            </div>
          </div>

          <br>

          <div class="layui-inline">
            <label class="layui-form-label">归属商务</label>
            <div class="layui-input-block">
              <select name="eb_id" lay-search>
                <option value="">请选择</option>
                {foreach $ebs as $k => $v}
                <option value="{$v.id}">{$v.account}</option>
                {/foreach}
              </select>
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">归属代理</label>
            <div class="layui-input-block">
              <select name="agent_id" lay-search>
                <option value="">请选择</option>
                {foreach $agents as $k => $v}
                <option value="{$v.id}">{$v.account}</option>
                {/foreach}
              </select>
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">归属投放号</label>
            <div class="layui-input-block">
              <select name="channel_id" lay-search>
                <option value="">请选择</option>
                {foreach $channels as $k => $v}
                <option value="{$v.id}">{$v.account}</option>
                {/foreach}
              </select>
            </div>
          </div>

          <br>

          <div class="layui-inline">
            <label class="layui-form-label">来源商务</label>
            <div class="layui-input-block">
              <select name="source_eb_id" lay-search>
                <option value="">请选择</option>
                {foreach $ebs as $k => $v}
                <option value="{$v.id}">{$v.account}</option>
                {/foreach}
              </select>
            </div>
          </div>


          <div class="layui-inline">
            <label class="layui-form-label">来源代理</label>
            <div class="layui-input-block">
              <select name="source_agent_id" lay-search>
                <option value="">请选择</option>
                {foreach $agents as $k => $v}
                <option value="{$v.id}">{$v.account}</option>
                {/foreach}
              </select>
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">来源投放号</label>
            <div class="layui-input-block">
              <select name="source_channel_id" lay-search>
                <option value="">请选择</option>
                {foreach $channels as $k => $v}
                <option value="{$v.id}">{$v.account}</option>
                {/foreach}
              </select>
            </div>
          </div>
          <br>

          <div class="layui-inline">
            <label class="layui-form-label">是否加桌</label>
            <div class="layui-input-block">
              <select name="add_shortcut">
                <option value="">请选择</option>
                <option value="1">已加桌</option>
                <option value="0">未加桌</option>
              </select>
            </div>
          </div>


          <div class="layui-inline">
            <label class="layui-form-label">是否付费</label>
            <div class="layui-input-block">
              <select name="is_pay">
                <option value="">请选择</option>
                <option value="1">已付费</option>
                <option value="2">未付费</option>
              </select>
            </div>
          </div>


          <div class="layui-inline">
            <label class="layui-form-label">读者身份</label>
            <div class="layui-input-block">
              <select name="is_vip">
                <option value="">请选择</option>
                <option value="1">vip会员</option>
                <option value="2">普通会员</option>
              </select>
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">手机绑定</label>
            <div class="layui-input-block">
              <select name="have_phone">
                <option value="">请选择</option>
                <option value="1">已绑定</option>
                <option value="2">未绑定</option>
              </select>
            </div>
          </div>

            <div class="layui-inline">
                <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>
              <button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="LAY-reset">重置</button>
            </div>

        </div>
      </div>
      <div class="layui-card-body">
        <table id="LAY-user-back-role" lay-filter="LAY-user-back-role"></table>
        <script type="text/html" id="vipTpl">
          {{#  if(d.vip_text == 'vip会员'){ }}
          <span class="layui-badge">vip会员</span>
          {{#  } else { }}
          <span class="layui-badge layui-bg-blue">普通会员</span>
          {{#  } }}
        </script>

        <script type="text/html" id="channelTpl">
          {{#  if(d.vip_text == 'vip会员'){ }}
          <span class="layui-badge">vip会员</span>
          {{#  } else { }}
          <span class="layui-badge layui-bg-blue">普通会员</span>
          {{#  } }}
        </script>

        <script type="text/html" id="regTpl">
          {{d.regtime}}
        </script>
        <script type="text/html" id="lastTpl">
          {{#  if(d.last_novel){ }}
          {{d.last_novel.title}}
          {{#  } else { }}

          {{#  } }}
        </script>

        <script type="text/html" id="table-useradmin-admin">
          <a class="layui-btn layui-btn-normal layui-btn-xs" lay-href="/user/info.html?id={{d.id}}" lay-text="{{d.id}} - 读者"><i class="layui-icon layui-icon-edit"></i>详情</a>
        </script>
      </div>
    </div>
  </div>

 <script src="/static/layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: '/static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index','table','admin'], function(){
    var $ = layui.$
    ,form = layui.form
    ,admin = layui.admin
    ,table = layui.table;

      //监听搜索
      form.on('submit(LAY-user-back-search)', function(data){
          var field = data.field;

          //执行重载
          table.reload('LAY-user-back-role', {
              where: field,
              page: {
                curr: 1  // 将页码重置为第一页
              }
          });
      });

    form.on('submit(LAY-reset)', function(data){
      var field = data.field;
      var formData = {
        "keyword": '',
        "token" : '',
        "userId" : '',
        "quick_id" : '',
        "eb_id" : '',
        "agent_id" : '',
        "channel_id" : '',
        "source_eb_id" : '',
        "source_agent_id" : '',
        "source_channel_id" : '',
        "add_shortcut" : '',
        "is_pay" : '',
        "is_vip" : '',
        "have_phone" : ''
      };
      form.val("listSearch", formData);
      form.render();
      table.reload('LAY-user-back-role', {
        where: formData
        ,page: {
          curr: 1  // 将页码重置为第一页
        }
      });
    });

    table.render({
      elem: '#LAY-user-back-role'
      , url: '/user/list' //模拟接口
      , even: true
      , cellMinWidth: 100
      , response: {
        statusCode: 1 //规定成功的状态码，本来是：0，现在统一改为1
      }
      , page: true //开启分页
      , limits: [10, 20, 30, 40, 50, 100]
      , limit: 20
      , cols: [
        [{field: 'id', width: 80, title: 'ID', rowspan: 2}
          , {
          field: 'name', title: 'App', templet: function (d) {
            if (d.quick_app) {
              //得到当前行数据，并拼接成自定义模板
              return d.quick_app.name
            } else {
              return '<span style="color:#c00; ">App不存在</span>';
            }
          }, rowspan: 2
        }
          , {field: 'vip_text', title: '读者身份', align: 'center', templet: '#vipTpl', rowspan: 2}
          , {
          field: 'pay_money_text', title: '余额', align: 'center', templet: function (d) {
            return d.book_coin + d.book_point
          }, rowspan: 2
        }
          , {field: 'pay_money_text', title: '总充值', align: 'center', rowspan: 2}
          , {field: 'pay_times', title: '充值笔数', align: 'center', rowspan: 2}
          , {field: 'provider', title: '机型', align: 'center', rowspan: 2}
          , {field: 'last_novel', title: '最近阅读', minWidth: 170,  templet: '#lastTpl', rowspan: 2}
          , {field: 'regtime', title: '注册时间', minWidth: 170,  templet: '#regTpl', rowspan: 2}
          , {field: 'ip_addr', title: '注册IP', minWidth: 170, rowspan: 2}
          , {align: 'center', title: '<span lay-tips="访问过其他投放号广告链接，用户后续的运营权和充值数据就会变更给新投放号和新代理">归属</span>', colspan: 3 }, {align: 'center', title: '注册来源', colspan: 4}
          , {
          title: '操作',
          width: 150,
          align: 'center',
          fixed: 'right',
          toolbar: '#table-useradmin-admin',
          rowspan: 2
        }], [
          {
            field: 'eb',align: 'center', title: '商务',minWidth: 150, templet: function (d) {
              if (d.eb) {
                //得到当前行数据，并拼接成自定义模板
                return d.eb.account
              } else {
                return '';
              }
            }, style:'background-color: #CDC;'
          },{
            field: 'agent', title: '代理', align: 'center',minWidth: 150, templet: function (d) {
              if (d.agent) {
                //得到当前行数据，并拼接成自定义模板
                return d.agent.account
              } else if (d.agent_id > 0) {
                return '<span style="color:#c00; ">代理信息异常</span>';
              } else {
                return '';
              }
            }, style:'background-color: #CDC;'
          }
          , {
            field: 'channel',align: 'center', title: '投放号',minWidth: 150, templet: function (d) {
              if (d.channel) {
                //得到当前行数据，并拼接成自定义模板
                return d.channel.account
              } else if (d.channel_id > 0) {
                return '<span style="color:#c00; ">投放号信息异常</span>';
              } else {
                return '';
              }
            }, style:'background-color: #CDC;'
          }
          , {
            field: 'source_eb', align: 'center',title: '商务', minWidth: 150,templet: function (d) {
              if (d.source_eb) {
                //得到当前行数据，并拼接成自定义模板
                return d.source_eb.account
              } else {
                return '';
              }
            }, style:'background-color: #DCB;'
          }
          ,{
            field: 'source_agent', align: 'center',title: '代理', minWidth: 150,templet: function (d) {
              if (d.source_agent) {
                //得到当前行数据，并拼接成自定义模板
                return d.source_agent.account
              } else if (d.source_agent_id > 0) {
                return '<span style="color:#c00; ">代理信息异常</span>';
              } else {
                return '';
              }
            }, style:'background-color: #DCB;'
          }
          , {
            field: 'source_channel',align: 'center', title: '投放号',minWidth: 150, templet: function (d) {
              if (d.source_channel) {
                //得到当前行数据，并拼接成自定义模板
                return d.source_channel.account
              } else if (d.source_channel_id > 0) {
                return '<span style="color:#c00; ">投放号信息异常</span>';
              } else {
                return '';
              }
            }, style:'background-color: #DCB;'
          }
        ]]
    });
  });
  </script>
</body>
</html>

